<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String path = request.getContextPath();%>
    	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    	<title>查看审核 </title>
<jsp:include page="/web/manager/inc/header.jsp"></jsp:include>
				<div class="row page-titles mx-0">
                        <div class="col-sm-6 p-md-0">
                            <div class="welcome-text">
                                <h4 class="text-primary">审核列表</h4>
                            </div>
                        </div>
                    </div>
				<div class="row">
                        <div class="col-lg-12">
			     <button class="badge badge-primary" id="noPassNum" onclick="noPassList()">未审核 <span >0</span></button>
				 <button class="badge badge-primary" id="" onclick="passList()">已审核</button>
				 
                            <div class="card">
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table id="example3" class="display nowrap">
                                            <thead>
                                                <tr>
                                                    <th>PostID</th>
                                                    <th>发帖时间</th>
                                                    <th>发帖人</th>
                                                    <th>标题</th>
                                                    <th>内容</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody id="postInfo">
                                                
                                               
                                            </tbody>
                                        </table>
                                    </div>
		                                 <p id="countPage">
		                                 共有<span id="pageNum"></span>条记录 
		                                 </p>
		                            
                                </div>
                            </div>
                        </div>
                    </div>

  <jsp:include page="/web/manager/inc/footer.jsp"></jsp:include>
  <style>
  .operation>span{
  	margin:0 10px;
  }
  #noPassNum{
	position:relative;  
  }
  #noPassNum span{
  display:block;
  	position:absolute;
  	background-color: red;
  	right:-5px; 
  	top:-5px;
  	width: 17px;
  	height: 18px;
  	text-align: center;
  	border-radius: 30%;
  }
  .color{
       background-color: green;
        }
   .pass,.nopass{
   display:block;
   	 width:80px;
   	 text-align: center;
   	 line-height: 25px;
   	 color:white;
   	 padding: 0;
   	 
   }
   .pass{
   	background-color: green;
   }
   .nopass{
   	background-color: red;
   }
   #whichPage{
   	width: 10px;
   	height: 6px;
   	background-color: gray;
   	border-radius: 10%;
   	margin: 5px;
   	padding: 5px;
   	color: white;
   
   }
   #whichPage:hover {
    cursor: pointer;
   } 
  </style>
  <script>
  var path = "${pageContext.request.contextPath}";
  var num = ${configMap.page_size};
  $(function(){
	  $("button").on("click",function(){
			$("button").removeClass("color");
			$(this).addClass("color");
		})
	  //加载页面，显示未审核的列表。请求ajax,默认第一页
	  $("#postInfo").on("click","#nopass",function(){
		  //执行ajax  将帖子设置成  2 未通过审核
		   //console.log($(this).data("nopass"));
		  $.post(path+"/ManagerController?action=clickNoPass&postId="+$(this).data("nopass"),function(){
			//从网页的列表中删除这条信息
			  $("#review").remove();
			  $("#noPassNum span").html( $("#noPassNum span").html()-1);
			  $("#pageNum").html($("#noPassNum span").html());
			  if($("#noPassNum span").html()==0){
				  $("#postInfo").html("<div >暂无内容</div>")
			  }
		  })
		  
		  
		  
	  })
	   $("#postInfo").on("click","#pass",function(){
		  //执行ajax  将帖子设置成 1 通过审核
		 $.post(path+"/ManagerController?action=clickPass&postId="+$(this).data("pass"),function(){
		 //从网页的列表中删除这条信息
			  $("#review").remove();
			  $("#noPassNum span").html( $("#noPassNum span").html()-1);
			  $("#pageNum").html($("#noPassNum span").html());
			  if($("#noPassNum span").html()==0){
				  $("#postInfo").html("<div >暂无内容</div>")
			  }
	  		})
	   })
	  noPassLoad();
  })
  //进入加载,显示全部，不用分页
  function noPassLoad(){
	  $("#postInfo").load(path+"/ManagerController?action=noPass",function(){
		  $("#countPage>a").remove();
			$.post(path+"/ManagerController?action=pageNumberNoPass",function(data){
				$("#pageNum").html(data);
				$("#noPassNum span").html(data);
			})
	  })
  }
  //点击按钮 切换到已审核列表
  function noPassList(){
	  noPassLoad();
  }
//---------------------------------------------------------------------------------------------------
  
  
  //点击按钮 切换到已审核列表
  function passList(){
	  //点击默认显示首页
	  $("#postInfo").load(path+"/ManagerController?action=passList&pageNum=0",function(){
	  })
		//显示页码
		refreshPassPage()
  }
	  
  
  function refreshPassPage(){
	  $("#countPage>a").remove();
		$.post(path+"/ManagerController?action=pageNumberPass",function(data){
			$("#pageNum").html(data);
			  var countPage ;
			if(data%num == 0){
				countPage=data/num;
			}
			else{
				countPage=Math.ceil(data/num);
			}
			for(var i=0;i<countPage;i++){
				$("#countPage").append("<a onclick='changePageList(this)' id='whichPage' data-page='"+i+"' >"+(i+1)+"</a>")
			}
		})
	  
  }
  function changePageList(obj){
	  $("#postInfo").load(path+"/ManagerController?action=passList&pageNum="+$(obj).data("page"),function (){
	  }
	  )
  }
  
  
  
  $(function(){
		$("#example3_paginate").remove();
		$("#example3_info").remove();
	})
  </script>